package com.myapplication.ui.listfragment.shoplistactivity;

import android.os.Handler;
import android.os.Looper;

import com.myapplication.bean.ShopListBean;

import java.util.List;
import java.util.Map;

/**
 * Created by zitaojiang on 2016/10/6.
 */
public class Presenter_ShopList implements Contract_ShopList.Presenter{
    Handler mHandler=new Handler(Looper.getMainLooper());
    private Contract_ShopList.View mView;
    private Contract_ShopList.Model mModel;

    public Presenter_ShopList(Contract_ShopList.View view){
        this.mView=view;
        mModel=new Model_ShopList();
    }
    @Override
    public void GetData(String type,Map<String, String> params) {

        mModel.getData(type, params, new Model_ShopList.SendShopListListener() {
            @Override
            public void sendShopList(List<ShopListBean.DataBean.ItemsBean> itemsBeanList) {
                if (itemsBeanList!=null){
                    mView.onGetDataSuccess(itemsBeanList);
                }else {
                    mView.onGetDataFail("wangluoshujujiazai shibai");
                }
            }
        });
//
//        mModel.getData(type,params, new Callback<ShopListBean>() {
//            @Override
//            public void onResponse(Call<ShopListBean> call, Response<ShopListBean> response) {
//                    ShopListBean shopListBean=response.body();
//                    Log.i("tag", "onResponse: "+shopListBean.toString());
//                    final List<ShopListBean.DataBean.ItemsBean> shoplistbean=shopListBean.getData().getItems();
//                    mHandler.post(new Runnable() {
//                        @Override
//                        public void run() {
//                            mView.onGetDataSuccess(shoplistbean);
//                        }
//                    });
//            }
//
//            @Override
//            public void onFailure(Call<ShopListBean> call, Throwable t) {
//                Log.i("tag1", "---------------: "+t.getMessage());
//                mHandler.post(new Runnable() {
//                    @Override
//                    public void run() {
//                        mView.onGetDataFail("网络连接失败");
//                    }
//                });
//            }
//        });
    }

}
